package com.ginage.gaugemanager.service.impl;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;
import com.ginage.gaugemanager.mapper.ILoginDao;
import com.ginage.gaugemanager.mapper.entity.User;
import com.ginage.gaugemanager.service.api.ILoginService;
import com.ginage.gaugemanager.utils.MD5;


@Service
public class LoginServiceImpl implements ILoginService {
	@Autowired
	ILoginDao dao;

	@Override
	public JSONObject checkUser(User user) {
		JSONObject jb = new JSONObject();
		String password = MD5.parse(user.getPassword());
		user.setPassword(password);
		User resultUser = dao.checkUser(user);
		if (resultUser == null) {
			jb.put("status", "failed");
			jb.put("info", "用户名或密码错误!");
		} else {
			jb.put("status", "success");
			jb.put("currentUser",resultUser);
			/*
			 * if(resultUser.getTouxiangPath()==null) { jb.put("touxiangPath",
			 * "images/touxiang1.png");
			 * 
			 * }else { jb.put("touxiangPath", resultUser.getTouxiangPath());
			 * 
			 * }
			 */
		}
		return jb;
	}

}
